package com.mic.yzzn.plc.model;

import com.mic.yzzn.plc.common.control.datastructure.PLCDataStatus;

import java.util.Date;

/**
 * Created by ASH on 16/4/18.
 */
public class PLCPointData {

	/** 取得数据的时间 */
    private Date time;
    
    /**
     * PLC采控系统与PLC交互的状态
     */
    private int status; 
    
    /** 对应点位数据 */
    private ContactPointData pointData;
    
    public PLCPointData(){}
    
    public PLCPointData(ContactPointData pointData, Date time, int status) {
		this.pointData = pointData;
		this.time = time;
		this.status = status;
		
	}

	public PLCPointData(String type, String point, String value, Date time, int status) {
		this.pointData = new ContactPointData(type, point, value);
		this.time = time;
		this.status = status;
		
	}

	@Override
	public String toString() {
		return "state: " + status + " " + pointData.toString();
	}

	public static PLCPointData errorData(int state) {
		PLCPointData errorData = new PLCPointData();
		errorData.setTime(new Date());
		errorData.setStatus(state);
		errorData.setPointData(new ContactPointData("ILLEGAL", "ILLEGAL", "NULL"));
		return errorData;
	}

	// getters and setters
	
    public ContactPointData getPointData() {
		return pointData;
	}

	public void setPointData(ContactPointData pointData) {
		this.pointData = pointData;
	}
	
	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}    
    
}
